home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr49 / 273_01.zip / STRIDEL.CC < prev    next >
Text File  |  1993-04-04  |  2KB  |  44 lines

  1. stridel(char *substr, char *str)
  2. /*
  3. ┌────────────────────────────────────────────────────────────────────┐
  4. │Purpose: To delete the string pointed to by *substr from the string │
  5. │         pointed to by *str ignoring case.                          │
  6. │                                                                    │
  7. │ Inputs: char *substr = pointer to substring to delete.             │
  8. │         char *str    = pointer to string to delete from.           │
  9. │                                                                    │
  10. │Outputs: substr deleted from str.                                   │
  11. │                                                                    │
  12. │ Return: = 0 substr not found in str.                               │
  13. │         = 1 substr deleted from str.                               │
  14. │                                                                    │
  15. │                                                                    │
  16. └────────────────────────────────────────────────────────────────────┘
  17. */
  18. {
  19. int lstr, lsubstr, rc=1, endoff, fromoff, remleng, x;
  20.  
  21.     lstr = strlen(str);
  22.     lsubstr = strlen(substr);
  23.  
  24.     x=0;
  25.     while(x <= (lstr - lsubstr)) {
  26.         rc = strnicmp(str + x,substr,lsubstr);
  27.         if(rc) x++;
  28.         else break;
  29.     }
  30.  
  31.     if(rc) return(0);
  32.     fromoff = x + lsubstr;
  33.     if(fromoff == lstr) {
  34.         *(str + x) = 0x00;
  35.         return(1);
  36.     }
  37.  
  38.     endoff = lstr - lsubstr;
  39.     remleng = lstr - fromoff;
  40.     memmove(str + x,str + fromoff, remleng);
  41.     *(str + endoff) = 0x00;
  42.     return(1);
  43. }
  44.